﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using BLL;
using IFactory;

public partial class Month_QuarterPlanDetail : System.Web.UI.Page
{
    Authentication dllAuthentication = new Authentication();
    QuarterPlanofManager dllQuarterPlanofManager = new QuarterPlanofManager();
    QuarterPlanDetailManager dllQuarterPlanDetailManager = new QuarterPlanDetailManager();
    protected void Page_Load(object sender, EventArgs e)
    {
        dllAuthentication.isLogin();
        if (!IsPostBack)
        {
            bindQuarterPlanGridView();
        }
    }

    /// <summary>
    /// 绑定年计划GridView
    /// </summary>
    /// <author>Grokyao</author>
    /// <date>2009-2-6</date>
    void bindQuarterPlanGridView()
    {
        object[] _value = new object[1];
        _value[0] = Utility.HttpHelp.getParamsInt("QuarterPlanId");
        this.gvlist.DataSource = dllQuarterPlanofManager.get(QuarterPlanofManager.field.QuarterPlanId.ToString(), _value);
        this.gvlist.DataBind();
        #region    截取字符串处理，是否显示查看年分解按钮
        for (int i = 0; i < this.gvlist.Rows.Count; i++)
        {
            object[] _valueQuarterPlanResolve = new object[1];
            _valueQuarterPlanResolve[0] = this.gvlist.DataKeys[i]["QuarterPlanId"].ToString();
            DataTable _quarterResolve = dllQuarterPlanDetailManager.get(QuarterPlanDetailManager.field.QuarterPlanId.ToString(), _valueQuarterPlanResolve);
            this.gdvQuarterResolve.DataSource = _quarterResolve;
            this.gdvQuarterResolve.DataBind();

        }
        #endregion
    }


    /// <summary>
    /// 绑定年分解GridView
    /// </summary>
    /// <author>Grokyao</author>
    /// <date>2009-2-6</date>
    void bindQuarterResolveGridView(int _quarterPlanId)
    {
        object[] _value = new object[1];
        _value[0] = _quarterPlanId;
        DataTable _quarterResolve = dllQuarterPlanDetailManager.get(QuarterPlanDetailManager.field.Id.ToString(), _value);

        this.gdvQuarterResolve.DataSource = _quarterResolve;
        this.gdvQuarterResolve.DataBind();

    }



    /// <summary>
    /// 查看年分解按钮事件
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnQuarterPlanResolve_Click(object sender, EventArgs e)
    {
        int i = 0;
        Button bt = (Button)sender;//获得当前控件
        TableCell cell = (TableCell)bt.Parent;//得到所处的父单元格
        GridViewRow iRow = (GridViewRow)cell.Parent;//得到所处父单元行
        i = iRow.RowIndex;//得到该行的索引
        string _quarterPlanId = this.gvlist.DataKeys[i]["QuarterPlanId"].ToString();
        string _quarterSortId = this.gvlist.Rows[i].Cells[0].Text;

        string _url = "QuarterResolveForMonth.aspx?_quarterPlanId=" + _quarterPlanId + "&_quarterPlanSortId=" + _quarterSortId;
        Page.RegisterStartupScript("windowsopen", "<script language=javascript>window.open('" + _url + "','quarterplandetailmodify','height=200,width=900,top=200,left=80,toolbar=no,menubar=no,scrollbars=yes,resizable=no,location=no,status=no');</script>");


    }
}
